// 06shoppingCart/01orderBefor/orderBefor.js
var _this, _TD
var co = require('../../resource/js/common.js')
var M = require('../../resource/js/md5.js')
var app = getApp()

Page({
   data: {
      shopConfig: '', //商城信息
      userInfo: '', //用户信息
      rental: [], //总价
      originalPrice: '', //没有优惠的价格
      remark: [], //留言
      expressage: [], //快递信息
      showModalExpress: false, //快递模态框
      expressageKey: [], //选择的快递序号
      carriage: 0, //快递费
      carriageList: [], //快递费列表
      address: '',
      isPitchOn: [], //是否需要发票
      invoiceContent: [], //发票内容
      usableCoupon: [], //可用的优惠劵
      usableCouponKey: [], //选择的优惠劵序号
      topCoupon: [], //上一张优惠劵优惠的价格
      showModalCoupon: false, //优惠劵模态框
      isIntegral: [false], //是否需要积分抵用
      integra: '', //消耗多少积分    
      sum: 0, //积分抵用金额
      total: 0.1, //所有商品总额
      modalZIndex: "", //模态框优先级
      details: '', //改版后的商品信息
      isNumber: true, //是否可以修改数量
      payMode: false, //选择支付方式模态框
      pasInput: false, //余额支付密码输入框
      ExpressCost: '', //物流费用
      orderID:'',//订单ID

   },

   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function(options) {
      _this = this
      _TD = this.data
      // 保存用户信息
      var user = app.Data.userInfo,
         param = JSON.parse(options.param)
      //console.log("【用户信息】==", user)
      //console.log('param',param)
      console.log('options', options)

      // 判断是否要显示修改数量
      if (param.length > 1) {
         this.setData({
            isNumber: false
         })
      }
      // 计算价格
      var rental = []
      var carriageList = []
      var usableCouponKey = []
      var remark = []
      var total = 0
      var topCoupon = []
      for (var k in param) {
         var money = 0
         for (var j in param[k].Order_CartList) {
            money += param[k].Order_CartList[j].Products_Price * param[k].Order_CartList[j].num
         }
         total += money
         money = money.toFixed(2)
         rental.push(money)
         carriageList.push(0)
         usableCouponKey.push[0]
         remark.push("")
         topCoupon.push(0)
      }
      //console.log("【价格数组】===", rental)
      //console.log("【所以商品总额】", total)


      //this.getShopConfig()
      var isPitchOn = []
      var isIntegral = []
      this.setData({
         userInfo: user,
         details: param,
         rental: rental,
         originalPrice: money,
         carriageList: carriageList,
         usableCouponKey: usableCouponKey,
         remark: remark,
         total: total.toFixed(2),
         topCoupon: topCoupon
      });
      for (var i in param) {
         var Biz_ID = param[i].Biz_ID
         // 获得店铺的快递方式
         //_this.getExpress(Biz_ID, i)
         // 获取个人优惠劵
         //_this.getHasCouponList(Biz_ID, i)
         isPitchOn.push(false)
         isIntegral.push(false)
      }
      this.setData({
         isPitchOn: isPitchOn,
         isIntegral: isIntegral
      })
      this.getUserAddress(user.User_ID) //获取用户地址
      this.getExpressCost() //获取快递费用
   },
   // 获取个人优惠劵
   // getHasCouponList: function (Biz_ID, index) {
   //    var User_ID = this.data.userInfo.User_ID,
   //       param = {
   //          User_ID: User_ID,
   //          Biz_ID: Biz_ID,
   //       };
   //    console.log("【优惠劵的param】", param)
   //    co.getMallApi('coupon/Cpmg/getHasCouponList', param, function (res) {
   //       if (res.code == 0) {
   //          console.log("【我的优惠劵】", res.data)
   //          _this.judgeUsableCoupon(res.data, index)
   //       }
   //    })
   // },
   // // 判断是否有可用优惠劵
   // judgeUsableCoupon: function (data, listIndex) {
   //    var list = data,
   //       rental = _TD.rental[listIndex],
   //       usableCoupon = [],
   //       index = _TD.usableCouponKey[listIndex];
   //    console.log("【listIndex】", listIndex)
   //    console.log("【rental】", rental)
   //    console.log("【index】", index)
   //    if (list.length > 0) {
   //       for (var j = 0; j < list.length; j++) {
   //          if (list[j].Coupon_Condition < rental) {
   //             usableCoupon.push(list[j])
   //          }
   //       }
   //       if (usableCoupon.length > 0) {
   //          if (!usableCoupon[index]) {
   //             index = 0
   //          }
   //       }
   //       var TDrental = _TD.rental
   //       var topCoupon = _TD.topCoupon
   //       TDrental[listIndex] = rental - usableCoupon[index].Coupon_Cash + topCoupon[listIndex]
   //       topCoupon[listIndex] = usableCoupon[index].Coupon_Cash
   //       var TDusableCoupon = _TD.usableCoupon
   //       TDusableCoupon[listIndex] = usableCoupon
   //       var usableCouponKey = _TD.usableCouponKey
   //       usableCouponKey[listIndex] = index
   //       var total = 0
   //       for (var i in TDrental) {
   //          total += parseFloat(TDrental[i])
   //       }
   //       this.setData({
   //          usableCoupon: TDusableCoupon,
   //          usableCouponKey: usableCouponKey,
   //          rental: TDrental,
   //          topCoupon: topCoupon,
   //          total: total.toFixed(2)
   //       })
   //    } else {
   //       console.log("【没有该店优惠劵】")
   //    }
   // },
   // 获取商城信息
   // getShopConfig: function (param) {
   //    _this = this
   //    co.getMallApi('/shop/Smg/getShopConfig', param, function (res) {
   //       if (res.code == 0) {
   //          console.log("【商城信息】", res.data)
   //          _this.setData({ shopConfig: res.data })
   //       }
   //    })
   // },
   // 从接口取出店铺快递的方式
   // getExpress: function (Bid, index) {
   //    // console.log("【bi的===============】",Bid)
   //    var param = { Biz_ID: Bid }
   //    co.getMallApi('biz/Bmg/getExpress', param, function (res) {
   //       if (res.code == 0) {
   //          var expressage = _TD.expressage
   //          console.log("【res.data】", typeof (res.data), res.data, JSON.stringify(res.data))
   //          if (JSON.stringify(res.data) == '[]') {
   //             expressage[index] = [{ Shipping_Name: '商家派送', express: null, isDefault: 1 }]
   //          } else {
   //             expressage[index] = res.data
   //          }
   //          _this.setData({ expressage: expressage })
   //          console.log("【店铺的快递方式】", expressage)
   //          // 取出店铺默认快递的序号
   //          for (var k in expressage[index]) {
   //             if (expressage[index][k].isDefault == 1) {
   //                console.log("【k的值】", k)
   //                var expressageKey = _TD.expressageKey
   //                expressageKey[index] = k
   //                _this.setData({ expressageKey: expressageKey })
   //             }
   //             console.log("【店铺的快递方式序号】", expressageKey)
   //          }
   //          if (index == _TD.details.length - 1) {
   //             _this.chargeCarriage()
   //          }
   //       }
   //    })
   // },
   // 获取买家留言
   // remark: function (e) {
   //    var index = e.currentTarget.dataset.index
   //    var remark = this.data.remark
   //    remark[index] = e.detail.value
   //    console.log("【留言】==", remark)
   //    console.log(e.detail.value)
   //    this.setData({ remark: remark })
   // },
   // input输入购买商品数量的值
   inputNumber: function(e) {
      if (!e.detail.value || e.detail < 1) {
         var num = 1
      } else {
         var num = e.detail.value
      }
      var detail = _TD.details,
         rental = _TD.rental,
         sum = _TD.sum;
      if (!_TD.isIntegral) {
         sum = 0
      }
      rental[0] = (detail[0].Order_CartList[0].ProductsPriceSku * num - sum).toFixed(2)
      detail[0].Order_CartList[0].Qty = num
      this.setData({
         details: detail,
         rental: rental,
         originalPrice: rental[0],
         total: rental[0]
      })
      this.chargeCarriage()
      //this.getHasCouponList()
   },
   // 商品数量加减
   increase: function() {
      var num = _TD.details[0].Order_CartList[0].Qty,
         details = _TD.details,
         carriage = parseFloat(_TD.carriage),
         unPrice = _TD.details[0].Order_CartList[0].ProductsPriceSku,
         sum = _TD.sum;
      num++
      if (!_TD.isIntegral[0]) {
         sum = 0
      }
      var rental = _TD.rental,
         originalPrice = parseFloat(num * unPrice);
      rental = [parseFloat(num * unPrice) + carriage - this.data.topCoupon[0] - sum]
      details[0].Order_CartList[0].Qty = num
      this.setData({
         details: details,
         rental: rental,
         originalPrice: originalPrice,
         total: rental[0]
      });
      this.chargeCarriage()
      //this.getHasCouponList(this.data.details[0].Biz_ID, 0)
   },
   reduce: function() {
      var num = _TD.details[0].Order_CartList[0].Qty,
         details = _TD.details,
         carriage = parseFloat(_TD.carriage),
         unPrice = _TD.details[0].Order_CartList[0].ProductsPriceSku,
         rental = _TD.rental,
         sum = _TD.sum;
      //console.log("将=======", _TD.shopConfig.Integral_Use_Laws[0].man, rental[0])
      if (!_TD.isIntegral[0]) {
         sum = 0
      }
      if (num > 1) {
         num--
         var originalPrice = parseFloat(num * unPrice);
         if (parseInt(_TD.shopConfig.Integral_Use_Laws[0].man) > parseInt(originalPrice)) {
            sum = 0
            this.setData({
               isIntegral: [false]
            })
         }
         rental = [parseFloat(num * unPrice) + carriage - this.data.topCoupon[0] - sum]
         details[0].Order_CartList[0].Qty = num
         this.setData({
            details: details,
            rental: rental,
            originalPrice: originalPrice,
            total: rental[0]
         });
         this.chargeCarriage()
         //this.getHasCouponList(this.data.details[0].Biz_ID, 0)
      }

   },
   // 快递费用计算
   // chargeCarriage: function() {
   //    // console.log("【商品详情】===", _TD.details)
   //    //console.log("【商品的快递】===", _TD.expressage)
   //    var money = [], //快递费列表
   //       totalMoney = 0, //快递总价
   //       weight = 0, //总重量
   //       rental = _TD.rental;
   //    //console.log("【保存的价格】==========", rental)
   //    for (var i in _TD.details) {
   //       // console.log("【expressageKey】", _TD.expressageKey, i, _TD.expressageKey[i])
   //       var expressage = _TD.expressage[i],
   //          index = _TD.expressageKey[i]
   //       var num = 0,
   //          weights = 0;
   //       for (var j in _TD.details[i].Order_CartList) {
   //          num += _TD.details[i].Order_CartList[j].Qty
   //          weights += parseFloat(_TD.details[i].Order_CartList[j].Products_Weight)
   //          //  console.log("【重量】=", weights, "【数量】=", num)
   //          //  console.log(_TD.details[i].Order_CartList[j])
   //       }
   //       weight = Math.ceil(weights * num)
   //       // console.log("【express】", expressage, index)
   //       if (expressage[index].express != null) {
   //          var express = expressage[index].express.default;
   //          if (expressage[index].By_Method == "by_weight") {
   //             // 按重量计算价格
   //             var mother = (weight - express.start) * (express.postageplus / express.plus) + parseInt(express.postage)
   //          } else if (expressage[index].By_Method == "by_qty") {
   //             // 按件计算价格
   //             var mother = (num - express.start) * (express.postageplus / express.plus) + parseInt(express.postage)
   //          }
   //       } else {
   //          var mother = 0
   //       }
   //       // console.log("【循环中的三个数据】====", i, parseFloat(rental[i]), mother, _TD.carriageList[i])
   //       money.push(mother)
   //       totalMoney += mother
   //       rental[i] = (parseFloat(rental[i]) + mother - _TD.carriageList[i]).toFixed(2)
   //    }
   //    var total = _TD.total
   //    total = parseFloat(total) + totalMoney - _TD.carriage
   //    //console.log("【加快递的总额】", total)
   //    this.setData({
   //       rental: rental,
   //       carriage: totalMoney.toFixed(2),
   //       carriageList: money,
   //       total: total.toFixed(2)
   //    })
   // },
   // // 是否需要发票
   // Invoice: function(e) {
   //    var index = e.currentTarget.dataset.index
   //    //console.log("【发票idnex】", index)
   //    var isPitchOn = _TD.isPitchOn
   //    isPitchOn[index] = !isPitchOn[index]
   //    this.setData({
   //       isPitchOn: isPitchOn
   //    })
   //    // console.log("【isPitchOn】===", isPitchOn)
   // },
   // // 发票内容
   // invoiceContent: function(e) {
   //    var content = e.detail.value
   //    var index = e.currentTarget.dataset.index
   //    var invoiceContent = _TD.invoiceContent
   //    invoiceContent[index] = content
   //    //  console.log("【发票内容】", invoiceContent)
   //    this.setData({
   //       invoiceContent: invoiceContent
   //    })
   // },
   // // 是否需要积分抵用
   // Integral: function(e) {
   //    var index = e.currentTarget.dataset.index
   //    //  console.log("【===================】", _TD.shopConfig)
   //    if (_TD.rental[index] < parseInt(_TD.shopConfig.Integral_Use_Laws[0].man)) {
   //       co.toast("满" + _TD.shopConfig.Integral_Use_Laws[0].man + "元可用")
   //    } else if (_TD.userInfo.User_Integral < _TD.shopConfig.Integral_Use_Laws[0].use) {
   //       co.toast("积分不足")
   //    } else {
   //       var isIntegral = _TD.isIntegral
   //       //    console.log("【积分数组1】", isIntegral, index)
   //       isIntegral[index] = !isIntegral[index]
   //       //   console.log("【积分数组2】", isIntegral)
   //       this.setData({
   //          isIntegral: isIntegral
   //       })
   //       var max = parseInt(_TD.shopConfig.Integral_Use_Laws[0].use),
   //          sum = _TD.shopConfig.Integral_Use_Laws[0].use / _TD.shopConfig.Integral_Buy,
   //          rental = _TD.rental;
   //       //   console.log("【max】", max)
   //       //   console.log("【sum】", sum)
   //       //   console.log("【rental】", rental[index])
   //       if (_TD.isIntegral[index]) {
   //          rental[index] = (parseFloat(rental[index]) - sum).toFixed(2)
   //       } else {
   //          rental[index] = (parseFloat(rental[index]) + sum).toFixed(2)
   //       }
   //       //   console.log("【积分的金额】", rental)
   //       this.setData({
   //          rental: rental,
   //          sum: sum,
   //          integra: max
   //       })
   //       this.orderTotals()
   //    }
   // },
   // orderTotals: function() {
   //    var rental = _TD.rental;
   //    var total = 0
   //    for (var i in rental) {
   //       total += parseFloat(rental[i])
   //    }
   //    this.setData({
   //       total: total.toFixed(2)
   //    })
   // },
   // 微信支付
   pay: function(money) {
      //console.log('app.Data==pay微信', app.Data)
      // _abstract = _TD.details[0].Biz_Shop_Name
      //金额为订单总价
      var appid = app.Data.app.appid
      var param = { //e.detail.value
         openid: app.Data.userInfo.Wx_Openid[appid],
         appid: appid,
         money: this.data.total,
         abstract: "旧约商城购物"
      }
      //console.log('微信param', param)
      co.getShareApi('api/Wxpay/createParam', param, function(res) {
         res.data.success = function(result) {
            //for (var i in orderID) {
            //添加用户支付记录
            _this.addUserRecord(function(res) {
               //添加商家支付记录。确保数据不易出错，按顺序先加付款方数据，再加收款方数据
               _this.addBizRecord()
            })
            _this.changeOrder()
            //co.toastAllText('支付成功')
            wx.redirectTo({
               url: '/04myCenter/11shoppingOrder/shoppingOrder?index=2',
            })
            // }
         }
         res.data.fail = function(result) {
            //co.toastAllText('支付失败')
            wx.redirectTo({
               url: '/04myCenter/11shoppingOrder/shoppingOrder?index=1',
            })
            console.log('【调起支付失败res】', result)
         }
         //调起微信支付
         wx.requestPayment(res.data)
      })
   },
   // 余额支付
   yuePay: function(money, pa) {
      //金额为订单总价
      //console.log("【钱====】", money)
      //console.log("【订单ID===】", orderID)
      var param = {
         Pay_From_ID: 'User_' + app.Data.userInfo.User_ID,
         Pay_Password: pa,
         Money: money,
         Pay_To_ID: 'Biz_' + 91,
         Abstract: '91商城购物',
         isMall: 1
      }
      co.getJyhsApi('money/Recorduser/balancePay', param, function(res) {
         if (res.code == 0) {
            co.updateUserBalance(res.data.New_Balance) //修改用户余额
            app.getWXUserInfo()//更新用户数据
            _this.changeOrder()
            _this.setData({
               pasInput: false
            })
            //co.toastAllText('支付成功')
            wx.redirectTo({
               url: '/04myCenter/11shoppingOrder/shoppingOrder?index=2',
            })            
         }else{
            //co.toastAllText('支付失败')
            wx.redirectTo({
               url: '/04myCenter/11shoppingOrder/shoppingOrder?index=1',
            })
         }
      })
   },
   // 余额支付输入密码
   pasForm: function(e) {
      console.log("【获取密码】===", e)
      var pa = M.md5(e.detail.value.pa)
      //console.log("【获取密码】===", pa)
      //console.log("【details】====", _TD.details)
      // if (_TD.details[0].Order_ID != undefined) {
      //    this.yuePay(_TD.total, pa, [_TD.details[0].Order_ID], [_TD.details[0].Order_CartList[0].Product_ID])
      // } else {
      this.yuePay(_TD.total, pa)
      // }
   },
   // // 清除已付款购物车物品
   // deleteShoppingCart: function(ProductID) {
   //    var param = {
   //       User_ID: _TD.userInfo.User_ID,
   //       Product_ID: ProductID
   //    }
   //    co.getMallApi('product/Pmg/deleteShoppingCart', param, function(res) {
   //       // console.log("【删除成功】", res)
   //    })
   // },
   //创建订单
   createOrderInfo: function() {
      var url = 'jyhs/Ordmg/save' 
      console.log('_TD',_TD)     
      this.setData({
         payMode: true
      })
      if (!this.data.address) {
         co.toast("请选择地址")
      } else if (_TD.orderID != '') {         
         _this.setData({
            payMode: true
         })
      } else {
         var param = {
            User_ID: app.Data.userInfo.User_ID,
            Order_CartList: JSON.stringify(_TD.details[0].Order_CartList),
            Biz_ID: 91,
            Order_Shipping_Prices: _TD.ExpressCost,
            Order_TotalAmount: _TD.total
         }                     
         co.getMealApi(url,param,function(res){
            if(res.code == 0){               
               _this.setData({
                  orderID:res.data
               })                      
            }
         })

        
      }
   },
   // 选择的支付方式
   payMode: function(e) {
      var mode = e.currentTarget.dataset.mode
      if (mode == 1) {
         //判断是否设置支付密码
         if (app.Data.userInfo.PayPassword_Is_Set == 0) {
            co.confirm('未设置支付密码', '取消', '前往设置', function(res) {
               if (res) {
                  wx.navigateTo({
                     url: "/04myCenter/02set/02bindPhone/bindPhone",
                  })
               }
            })
            return
         }
         //如果余额为零自动跳转为微信支付
         if (app.Data.userInfo.User_Balance == 0) {
            co.toast('您的账户余额为零，请充值')
            return
         }
         if (parseInt(app.Data.userInfo.User_Balance) < parseInt(this.data.total)) {
            co.toast('您的余额不足，请充值')
            return
         }
         this.setData({
            payMode: false,
            pasInput: true
         })
      } else if (mode == 2) {
         console.log('_TD', _TD)
         // if (_TD.details[0].Order_ID != undefined) {
         //    this.pay(_TD.total, _TD.shopConfig.ShopName, [_TD.details[0].Order_ID], [_TD.details[0].Order_CartList[0].Product_ID])
         // } else {
         this.pay(_TD.total)
         //}
         this.setData({
            payMode: false
         })
      }
   },
   // 模态框中的快递以及优惠劵的选择
   // choose: function (e) {
   //    if (e.currentTarget.dataset.id == 1) {
   //       var key = e.currentTarget.dataset.expressage;
   //       var expressageKey = _TD.expressageKey;
   //       expressageKey[_TD.modalZIndex] = key
   //       // console.log("key", key)
   //       // console.log("index", _TD.modalZIndex)
   //       // console.log("【快递序号】", expressageKey)
   //       this.setData({ expressageKey: expressageKey })
   //       this.chargeCarriage()
   //       this.hideModal(e);
   //    } else {
   //       var key = e.currentTarget.dataset.coupon;       //选择的优惠劵编号
   //       var usableCouponKey = _TD.usableCouponKey;
   //       usableCouponKey[_TD.modalZIndex] = key
   //       this.setData({
   //          usableCouponKey: usableCouponKey,
   //       })
   //       // console.log("【modalZIndex】", _TD.modalZIndex)
   //       // console.log("【点击传送的】", _TD.usableCoupon[_TD.modalZIndex])
   //       // console.log("【点击传送的】", _TD.modalZIndex)
   //       this.judgeUsableCoupon(_TD.usableCoupon[_TD.modalZIndex], _TD.modalZIndex)
   //       this.hideModal(e);
   //    }
   // },
   //显示模态框
   // showDialogBtn: function (e) {
   //    var index = e.currentTarget.dataset.id
   //    var modalIndex = e.currentTarget.dataset.index
   //    if (index == 1) {
   //       this.setData({
   //          showModalExpress: true,
   //          modalZIndex: modalIndex
   //       })
   //    } else {
   //       this.setData({
   //          showModalCoupon: true,
   //          modalZIndex: modalIndex
   //       })
   //    }
   // },
   //隐藏模态对话框
   hideModal: function(e) {
      var index = e.currentTarget.dataset.id
      if (index == 1) {
         this.setData({
            showModalExpress: false
         });
      } else if (index == 2) {
         this.setData({
            showModalCoupon: false
         })
      } else if (index == 3) {
         this.setData({
            payMode: false
         })
      }
   },
   //跳转到选择快递地址
   toAddress: function() {
      wx.navigateTo({
         url: '/04myCenter/03recevingAddress/01personalAddress/personalAddress'
      })
   },
   //用户的快递地址
   getUserAddress: function(uid) {
      var param = {
            User_ID: uid
         },
         address
      co.getShareApi('address/Addrmg/getDefaultAddress', param, function(res) {
         if (res.code == 0) {
            address = res.data
            _this.setData({
               address: address
            })
         }
      })
   },
   //获取物流费用
   getExpressCost: function() {
      var url = 'jyhs/Shippingmg/getExpressCost'
      console.log('12', _TD)
      console.log('_TD.details[0].Order_CartList', _TD.details)
      var param = {
         Order_CartList: JSON.stringify(_TD.details[0].Order_CartList),
      }
      console.log('param', param)
      co.getMealApi(url, param, function(res) {
         if (res.code == 0) {
            _this.setData({
               ExpressCost: res.data
            })
         }
         console.log('res', res)
      })
   },
   //添加用户支付记录
   addUserRecord: function(callback) {
      var userInfo = app.Data.userInfo
      var url = 'money/Recorduser/userAdd'
      var uRecord = {
         User_ID: userInfo.User_ID,
         Abstract: '91商城消费',
         Payer: 'Biz_' + 91,
         Money: -_TD.total,
         Pay_From: 'wx_pay',
         Pay_To: '91_pay',
         isMall: 1
      }
      co.getJyhsApi(url, uRecord, function(res) {
         if (typeof(callback) == 'function') {
            callback()
         }
         if (res.code == 0) {

         } else {
            co.modal(res.msg)
         }
      })
   },
   //添加商家支付记录
   addBizRecord: function() {
      var userInfo = app.Data.userInfo
      var url = 'money/Recordbiz/bizAdd'
      var bizRecord = {
         Biz_ID: 91,
         Abstract: userInfo.User_NickName + '91商城购物',
         Payer: 'User_' + userInfo.User_ID,
         Money: _TD.total,
         Pay_From: 'wx_pay',
         Pay_To: '91_pay',
         // isMall:1
      }
      co.getJyhsApi(url, bizRecord, function(res) {
         if (res.code == 0) {
            co.modal(res.msg)
         } else {
            co.modal(res.msg)
         }
      })
   },
   //忘记密码
   retrievePwd: function() {
      wx.navigateTo({
         url: '/04myCenter/02set/02changePayPwd/01retrievePassword/retrievePassword',
      })
   },
   //关闭输入密码
   payClose: function() {
      var index = 1
      _this.setData({
         pasInput: false
      })
      wx.redirectTo({
         url: '/04myCenter/11shoppingOrder/shoppingOrder?index=' + index,
      })
   },
   //更新订单状态
   changeOrder: function() {
      var Order_ID = _TD.orderID
      var param = {
         Order_ID: Order_ID,
         Order_Status: 2
      }
      co.getMealApi('jyhs/Ordmg/updateStatus', param, function(res) {
         console.log("支付成功", res.data)
         //_this.deleteShoppingCart(ProductID)清除购物车
         wx.navigateTo({
            url: '/04myCenter/11shoppingOrder/shoppingOrder?index=1',
         })
      })
   },
   onShow:function(){
      var user = app.Data.userInfo
      this.getUserAddress(user.User_ID)
   }
   
})